<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui"
	xmlns:f="http://java.sun.com/jsf/core">
	<f:view>
		<p:commandButton value="Novo Cadastro" action="#{clienteManager.prepareSave}" ajax="false"/>
		
		<p:panel header="Filtros" styleClass="filtros" id="panel_filtros">
			<h:panelGrid columns="4">
				<h:outputText value="Nome" />
				<p:inputText value="#{clienteManager.clienteSearch.pessoa.nome}" />
				
				<h:outputText value="CPF"/>
				<p:inputMask id="cpf" mask="999.999.999-99" value="#{clienteManager.clienteSearch.pessoa.cpf}" label="CPF" converter="cpfConverter" />
			
				<p:commandButton value="Procurar" action="#{clienteManager.search}" update=":form" process=":form:panel_filtros"/>
			
			</h:panelGrid>
		</p:panel>
		
		<p:dataTable value="#{clienteManager.clientes}" var="m" rows="5" paginator="true"
		emptyMessage="Não existem resultados."
		>
			<p:column headerText="Nome">
				<h:outputText value="#{m.pessoa.displayNome}" />
			</p:column>
			<p:column headerText="CPF">
				<h:outputText value="#{m.pessoa.displayDocumento}" />
			</p:column>
			<p:column headerText="Ação">
				<p:commandButton value="Atualizar" action="#{clienteManager.prepareUpdate}" process="@this" update=":form">
					<f:setPropertyActionListener target="#{clienteManager.cliente}" value="#{m}" />
				</p:commandButton>
			</p:column>
			
		</p:dataTable>
	</f:view>
</html>